package base.day21.MyHashSet2;

import base.day20.Student;

import java.util.Comparator;
import java.util.TreeMap;
import java.util.TreeSet;

public class MyTreeMap1 {
    public static void main(String[] args) {
        TreeMap<Student,String> tm=new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                int result=o1.getAge()-o2.getAge();
                result=result==0?o1.getName().compareTo(o2.getName()):result;
                return result;
            }
        });
        Student stu1=new Student("zhangsan",23);
        Student stu2=new Student("lisi",24);
        Student stu3=new Student("wangwu",25);
        Student stu4=new Student("zhaoliu",26);
        Student stu5=new Student("qinqi",27);

        tm.put(stu1,"一号");
        tm.put(stu2,"二号");
        tm.put(stu3,"三号");
        tm.put(stu4,"四号");
        tm.put(stu5,"五号");

        tm.forEach(
                (Student key,String value) -> System.out.println(key+value)
        );

    }

}
